

************************
**   DiD Tables ********
************************

capt drop _est_*


local Outcomelist collapsed IntoCollapse
foreach outcome of local Outcomelist {

xtset id_eez_tax iyear
reghdfe `outcome'  $Treatment  ///
, absorb( i.id_eez_tax i.iyear)  cluster($ClusterLevel) 
distinct id_eez_tax  if e(sample)==1
estadd scalar K1 = r(ndistinct) , replace
sum iyear if e(sample)==1
estadd  local Period "`r(min)'-`r(max)'"   , replace
sum F1.`outcome' if e(sample)==1 
estadd scalar Mean = r(mean) , replace
estadd  local Controls "No"   , replace
estadd  local FE "EEZ-species"   , replace
sum years_of_ppr_cc if e(sample)==1 & $TreatmentGroup==1 & years_of_ppr_cc!=0
estadd scalar YearsOfPPR = round(`r(mean)', .01) , replace
eststo DID_`outcome'_1


xtset id_eez_tax iyear
reghdfe `outcome'  $Treatment  ///
$ControlsShort ///
, absorb( i.id_eez_tax i.iyear)  cluster($ClusterLevel) 
distinct id_eez_tax  if e(sample)==1
estadd scalar K1 = r(ndistinct) , replace
sum iyear if e(sample)==1
estadd  local Period "`r(min)'-`r(max)'"   , replace
sum F1.`outcome' if e(sample)==1
estadd scalar Mean = r(mean) , replace
estadd  local Controls "Short"   , replace
estadd  local FE "EEZ-species"   , replace
sum years_of_ppr_cc if e(sample)==1 & $TreatmentGroup==1 & years_of_ppr_cc!=0
estadd scalar YearsOfPPR = round(`r(mean)', .01) , replace
eststo DID_`outcome'_2


xtset id_eez_tax iyear
reghdfe `outcome' $Treatment    ///
$ControlsMedium ///
, absorb( i.id_eez_tax   i.iyear)  cluster($ClusterLevel) 
distinct id_eez_tax  if e(sample)==1
estadd scalar K1 = r(ndistinct) , replace
sum iyear if e(sample)==1
estadd  local Period "`r(min)'-`r(max)'"   , replace
sum F1.`outcome' if e(sample)==1
estadd scalar Mean = r(mean) , replace
estadd  local Controls "Medium"   , replace
estadd  local FE "EEZ-species"   , replace
sum years_of_ppr_cc if e(sample)==1 & $TreatmentGroup==1 & years_of_ppr_cc!=0
estadd scalar YearsOfPPR = round(`r(mean)', .01) , replace
eststo DID_`outcome'_3


xtset id_eez_tax iyear
reghdfe `outcome' $Treatment    ///
$ControlsLong ///
, absorb( i.id_eez_tax   i.iyear)  cluster($ClusterLevel) 
distinct id_eez_tax  if e(sample)==1
estadd scalar K1 = r(ndistinct) , replace
sum iyear if e(sample)==1
estadd  local Period "`r(min)'-`r(max)'"   , replace
sum F1.`outcome' if e(sample)==1
estadd scalar Mean = r(mean) , replace
estadd  local Controls "Long"   , replace
estadd  local FE "EEZ-species"   , replace
sum years_of_ppr_cc if e(sample)==1 & $TreatmentGroup==1 & years_of_ppr_cc!=0
estadd scalar YearsOfPPR = round(`r(mean)', .01) , replace
eststo DID_`outcome'_4
}


** Make a table with both outcome variables
esttab  ///
DID_collapsed_1 ///
DID_collapsed_2 ///
DID_collapsed_3 ///
DID_collapsed_4 ///
using "${tables}DID_collapsed_plain_20170921.tex", ///
keep($Treatment) ///
nomtitles nogap  fragment noobs nonotes nonumbers collabels(none)  noline ///
star(* 0.10 ** 0.05 *** 0.01) se ///
coeflabels( $Treatment "PPR"  ) ///
replace


esttab  ///
DID_IntoCollapse_1 ///
DID_IntoCollapse_2 ///
DID_IntoCollapse_3 ///
DID_IntoCollapse_4 ///
using "${tables}DID_IntoCollapse_plain_20170921.tex", ///
keep($Treatment) ///
nomtitles nogap  fragment noobs nonotes nonumbers collabels(none)  noline ///
star(* 0.10 ** 0.05 *** 0.01) se  ///
coeflabels( $Treatment "PPR"  ) ///
replace



* Info for the table:
estimates restore DID_IntoCollapse_1
sum collapsed if e(sample)==1
estadd scalar MeanCol = r(mean) , replace
sum IntoCollapse if e(sample)==1
estadd scalar MeanIntoCol = r(mean) , replace
distinct eez if e(sample)==1 
estadd scalar EEZ = r(ndistinct)  , replace
eststo DID_IntoCollapse_1_v2
*
estimates restore DID_IntoCollapse_2
sum collapsed if e(sample)==1
estadd scalar MeanCol = r(mean) , replace
sum IntoCollapse if e(sample)==1
estadd scalar MeanIntoCol = r(mean) , replace
distinct eez if e(sample)==1 
estadd scalar EEZ = r(ndistinct)  , replace
eststo DID_IntoCollapse_2_v2
*
estimates restore DID_IntoCollapse_3
sum collapsed if e(sample)==1
estadd scalar MeanCol = r(mean) , replace
sum IntoCollapse if e(sample)==1
estadd scalar MeanIntoCol = r(mean) , replace
distinct eez if e(sample)==1 
estadd scalar EEZ = r(ndistinct)  , replace
eststo DID_IntoCollapse_3_v2
*
estimates restore DID_IntoCollapse_4
sum collapsed if e(sample)==1
estadd scalar MeanCol = r(mean) , replace
sum IntoCollapse if e(sample)==1
estadd scalar MeanIntoCol = r(mean) , replace
distinct eez if e(sample)==1 
estadd scalar EEZ = r(ndistinct)  , replace
eststo DID_IntoCollapse_4_v2


esttab  ///
DID_IntoCollapse_1_v2 ///
DID_IntoCollapse_2_v2   ///
DID_IntoCollapse_3_v2 ///
DID_IntoCollapse_4_v2 ///
using "${tables}DID_info_20170921.tex", ///
drop(*) ///
nomtitles nogap  fragment  noline nonumbers ///
star(* 0.10 ** 0.05 *** 0.01) ///  
stats(Controls  N Period N_clust EEZ K1 MeanCol MeanIntoCol YearsOfPPR ///
,label( "Controls (time-varying)"    "Obs" "Period" ///
"Countries" "EEZs" "EEZ-species" "Mean collapse (persistent)" "Mean collapse (transition)"  ///
"Mean years of PPR"   )) ///
se   coeflabels( $Treatment "PPR"  ) ///
replace

************************************

capt drop _est_*


